package com.unidt.www.module.system.dal.mysql.system;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.unidt.www.framework.mybatis.core.mapper.BaseMapperX;
import com.unidt.www.module.system.dal.dataobject.system.SystemDateDo;
import org.apache.ibatis.annotations.Mapper;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author sk
 * @Description:
 * @Date 2023/2/1 9:58
 **/
@Mapper
public interface SystemDateMapper extends BaseMapperX<SystemDateDo> {

    default List<String> getList(Date startTime, Date endTime){

        List<String> timeList = new ArrayList<>();
        LambdaQueryWrapper<SystemDateDo> lambdaQueryWrapper = new LambdaQueryWrapper();

        lambdaQueryWrapper.ge(SystemDateDo::getDate,startTime);
        lambdaQueryWrapper.lt(SystemDateDo::getDate,endTime);

        List<SystemDateDo> list =  this.selectList(lambdaQueryWrapper);

        list.forEach(e->{
          String time =    DateUtil.formatDate(e.getDate());
            timeList.add(time);
        });
        return  timeList;
    }
}
